// 通过defineStore可以定义小仓库(模块),该函数接受两个参数,第一个参数是模块的标识,第二个参数是配置对象
import {defineStore} from "pinia";
import {getUser} from "@/api/request.js";

const user = defineStore("user", {
    //存储数据:state
    state: () => {
        return {
            userData: {},
            menuData: [],
            buttonData: []
        }
    },
    actions: {
        // 获取用户信息
        async getUserInfo() {
            const {data} = await getUser();
            this.userData = data.userInfo;
            this.menuData = data.menu;
            this.buttonData = data.button;
        }
    },
    getters: {}

})
export default user;